package com.ja.openchat.ui.me;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import androidx.annotation.Nullable;

import com.ja.openchat.BR;
import com.ja.openchat.R;
import com.ja.openchat.databinding.FragmentSetPayPwdBinding;
import com.ja.openchat.viewmodels.SetPayPwdViewModel;
import com.zy.openchat.util.KeyboardHelper;

import me.goldze.mvvmhabit.base.BaseFragment;

//设置支付密码
public class SetPayPwdFragment extends BaseFragment<FragmentSetPayPwdBinding, SetPayPwdViewModel> {
    String textOld = "";

    @Override
    public int initContentView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return R.layout.fragment_set_pay_pwd;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public void initView() {
        super.initView();
        if (getArguments() != null) {
            textOld = getArguments().getString("textOld");
        }
        binding.verCodeViewOld.postDelayed(() -> {
            try {
                binding.verCodeViewOld.getEdit().requestFocus();
                KeyboardHelper.openKeyBoard(getContext(), binding.verCodeViewOld.getEdit());
            } catch (Exception e) {
                e.printStackTrace();
            }
        }, 500);
        binding.verCodeViewOld.setOnInputFinishListener(text -> {
            Bundle bundle = new Bundle();
            bundle.putString("text", text);
            bundle.putString("textOld", textOld);
            startContainerActivity(SetPayPwdConfirmFragment.class.getCanonicalName(), bundle);
        });
    }
}